﻿/********************************************************************************/
// <copyright file="BilanguageEntityBase.cs" company="Asia E-Business Solutions">
//     Copyright © 2012. All right reserved
// </copyright>
//
// <history>
//  <change who="Hieu Nguyen" date="11/12/2012 2:12:21 PM">Created</change>
// <history>
/********************************************************************************/

namespace JLL.China.Model
{
    using System.ComponentModel;
    using JLL.China.Infrastructure.DomainBase;
    using JLL.China.Model.Extensions;

    public abstract class BilanguageEntityBase<T> : EntityBase<T>, IBilanguageContent, IEntity<T> where T : new()
    {
        /// <summary>
        /// Default Constructor.
        /// </summary>
        protected BilanguageEntityBase()
            : base(default(T))
        {
        }

        /// <summary>
        /// Overloaded constructor.
        /// </summary>
        /// <param name="key">An <see cref="System.Object"/> that 
        /// represents the primary identifier value for the 
        /// class.</param>
        protected BilanguageEntityBase(T key)
            : base(key)
        {
        }

        #region  -- IBilanguageContent Members --

        public string Name { get; set; }
        public string Descriptions { get; set; }
        [DisplayName("Name in Vietnamese")]
        public string NameVI { get; set; }
        [DisplayName("Descriptions in Vietnamese")]
        public string DescriptionsVI { get; set; }

        public string GetLocalizedName()
        {
            if (System.Threading.Thread.CurrentThread.CurrentUICulture.ToString().Contains("vi"))
            {
                return NameVI;
            }
            else
            {
                return Name;
            }
        }

        public string GetLocalizedDescriptions()
        {
            if (System.Threading.Thread.CurrentThread.CurrentUICulture.ToString().Contains("vi"))
            {
                return DescriptionsVI;
            }
            else
            {
                return Descriptions;
            }
        }

        public string GetLocalizedDescriptions(int words)
        {
            return GetLocalizedDescriptions().GetPlainTextWords(words);
        }
        #endregion
    }
}
